bitkeeper revision 1.1373 (426a2bc8m7wX71OOkLtSOgNXcrObMA)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 23 Apr 2005 11:04:40 +0000 (11:04 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 23 Apr 2005 11:04:40 +0000 (11:04 +0000)
xc_domain.c:
  Ensure ctxt is mlocked in xc_domain_getfullinfo.

tools/libxc/xc_domain.c

index 919145e297448f69cf05bc0056a2efa65192d080..1d8815a8a67c53e8b878c56709418bc4a92ef824 100644 (file)
@@ -146,7 +146,7 @@ int xc_domain_getfullinfo(int xc_handle,
                           xc_domaininfo_t *info,
                           full_execution_context_t *ctxt)
 {
-    int rc;
+    int rc, errno_saved;
     dom0_op_t op;
 
     op.cmd = DOM0_GETDOMAININFO;
@@ -154,12 +154,23 @@ int xc_domain_getfullinfo(int xc_handle,
     op.u.getdomaininfo.exec_domain = (u16)vcpu;
     op.u.getdomaininfo.ctxt = ctxt;
 
+    if ( (ctxt != NULL) &&
+         ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) )
+        return rc;
+
     rc = do_dom0_op(xc_handle, &op);
 
-    if ( info )
+    if ( ctxt != NULL )
+    {
+        errno_saved = errno;
+        (void)munlock(ctxt, sizeof(*ctxt));
+        errno = errno_saved;
+    }
+
+    if ( info != NULL )
         memcpy(info, &op.u.getdomaininfo, sizeof(*info));
 
-    if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 )
+    if ( ((u16)op.u.getdomaininfo.domain != domid) && (rc > 0) )
         return -ESRCH;
     else
         return rc;